define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'subdstrict/index' + location.search,
                    /*add_url: 'subdstrict/add',*/
                    edit_url: 'subdstrict/edit',
                    /*del_url: 'subdstrict/del',
                    multi_url: 'subdstrict/multi',
                    import_url: 'subdstrict/import',*/
                    table: 'address_location',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),searchable:false},
                        /*{field: 'uid', title: __('Uid')},*/
                        /*{field: 'type', title: __('Type'), searchList: {"admin":__('Admin'),"manage":__('Manage')}, formatter: Table.api.formatter.normal},*/
                        {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
                        {field: 'user.mobile', title:'手机号', operate: 'LIKE'},
                        {field: 'province', title: '省', operate: 'LIKE',searchable:false},
                        {field: 'city', title: '市', operate: 'LIKE',searchable:false},
                        {field: 'county', title: '区', operate: 'LIKE',searchable:false},
                        {field: 'town_name1', title: '街道', operate: 'LIKE',searchable:false},
                        {field: 'town_name2', title: '社区', operate: 'LIKE',searchable:false},
                        {field: 'detail', title: '小区', operate: 'LIKE',searchable:false},
                        {field: 'source_name', title: '来源',searchable:false},
                        {field: 'create_time', title: '创建时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false,searchable:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
